import UIKit
import WeexSDK
class ViewController: UIViewController {
    fileprivate var instance: WXSDKInstance?
    fileprivate var weexView = UIView()
    
    
    //当controller 显示的时候手动隐藏
    override func viewWillAppear(_ animated: Bool) {
        navigationController?.setNavigationBarHidden(true, animated: false)
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        title = "测试"
        view.backgroundColor = .white
 navigationController?.setNavigationBarHidden(true, animated: false)
        render()
    }
    
    
    func render() {
        instance?.destroy()
        instance = WXSDKInstance()
        instance?.viewController = self
        instance?.frame = CGRect(origin: .zero, size: view.bounds.size)
     
        
        instance?.onCreate = { [unowned self] view in
            guard let v = view else { return }
            self.weexView.removeFromSuperview()
            self.weexView = v
            self.view.addSubview(self.weexView)
            UIAccessibility.post(notification: UIAccessibility.Notification.screenChanged, argument: v)
        }
        
        instance?.onFailed = { error in
            
         }
        
        instance?.renderFinish = { [weak self] view in
         
        }
        instance?.updateFinish = { view in
  
        }
        let jsURL = URL(string:"https://miniprogramf.applinzi.com/static/weex/demo.weex")
        instance?.render(with: jsURL, options: ["bundleUrl":jsURL!], data: nil)
        WeexMap.shared.dictMap["home"] = instance
    }
    


}

